﻿using LibNiconico.NiconicoApi;
using LibNiconico.NiconicoApi.Lives;
using LibNiconico.NiconicoApi.PlayerStatus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NicoView.Model.Service.Lives
{
    public sealed class NicoLiveServiceInfo : NicoServiceInfoBase
    {
        internal NicoPlayerStatus PlayerStatus { get; set; }



        public NicoLiveServiceInfo(NicoPlayerStatus playerStatus)
        {
            setPlayerStatus(playerStatus);
            
        }


        protected internal override string Ab_Title
        {
            get;
            set;
        }

        protected internal override string Ab_Description
        {
            get;
            set;
        }

        protected internal override string Ab_CommunityId
        {
            get;
            set;
        }

        protected internal override string Ab_Id
        {
            get;
            set;
        }




        private void setPlayerStatus(NicoPlayerStatus playerStatus)
        {
            PlayerStatus = playerStatus;
            Ab_Title = this.PlayerStatus.Stream.Title;
            Ab_Description = this.PlayerStatus.Stream.Description;
            Ab_CommunityId = this.PlayerStatus.Stream.DefaultCommunity;
            Ab_Id = this.PlayerStatus.Stream.Id;
            Ab_StartTime = this.PlayerStatus.Stream.StartTime;
            Ab_ThumbnailImagePath = "";
            this.IsOwner = playerStatus.Stream.IsOwner;
            this.IsPremium = playerStatus.User.IsPremium;

            this.endElapsedtime = this.EndTime - this.StartTime;
        }


        public void SetPlayerStatus(NicoPlayerStatus playerStatus)
        {
            setPlayerStatus(playerStatus);
            RaisePropertyChangedAll();
        }

        protected internal override DateTime Ab_StartTime
        {
            get;
            set;
        }

        protected internal override string Ab_ThumbnailImagePath
        {
            get;
            set;
        }

        public DateTime EndTime
        {
            get
            {
                return this.PlayerStatus.Stream.EndTime;
            }
        }


        private TimeSpan endElapsedtime;

        public override TimeSpan EndElapsedTime
        {
            get
            {
                return this.endElapsedtime;
            }

        }


        public bool IsPremium { get; private set; }

    }
}
